package cn.usian.controller;

import cn.usian.pojo.Emp;
import cn.usian.service.EmpService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

//分页+逻辑删除+多条件查询
//分页+逻辑删除+多条件查询
//分页+逻辑删除+多条件查询
@Controller
@RequestMapping("emp")
public class EmpController {
    @Autowired
    private EmpService empService;

    @GetMapping("findPage")
    public String findPage(String name,String age, Model model, @RequestParam(required = true,defaultValue = "1")Integer pageNum){
        Page<Emp> page =  empService.findPage(name,age,pageNum);
        model.addAttribute("list",page);
        return "emp";
    }


    @GetMapping("updelete")
    public String updelete(int id){
        empService.updelete(id);
        return "redirect:findPage";
    }
}
